package com.xiaoyu.ftp;

import java.io.IOException;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;

public class FunctionSet {
	@SuppressWarnings("unused")
	private FTPClient createFTPClien(FTPVo vo) throws IOException {
		FTPClient client = new FTPClient();
		int reply = -1;
		client.connect(vo.getHostName(), vo.getPort());
		client.login(vo.getUsername(), vo.getPassword());
		reply = client.getReplyCode();
		if (!(FTPReply.isPositiveCompletion(reply))) {
			client.disconnect();
			return null;
		}
		client.setControlEncoding(vo.getRemoteEncoding());
		client.setFileType(2);
		if (vo.isPassiveMode())
			client.enterLocalPassiveMode();
		else {
			client.enterRemotePassiveMode();
		}
		client.cwd(vo.getRemoteDir());
		return client;
	}
}